package com.briup.recognition.service.impl;

import com.briup.recognition.bean.GreenhouseMessage;
import com.briup.recognition.bean.GreenhouseMessageExample;
import com.briup.recognition.dao.GreenhouseMessageMapper;
import com.briup.recognition.service.IGreenhouseMessageService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * @program: recognition
 * @description:
 * @author: charles
 * @create: 2021-03-28 15:11
 **/

@Service
public class GreenhouseMessageServiceImpl implements IGreenhouseMessageService {

    @Resource
    private GreenhouseMessageMapper GreenhouseMessageMapper;

    @Override
    public List<GreenhouseMessage> query() {
        GreenhouseMessageExample example = new GreenhouseMessageExample();
        // 条件

        return GreenhouseMessageMapper.selectByExample(example);
    }

    @Override
    public void saveOrUpdate(GreenhouseMessage GreenhouseMessage) {
        if(GreenhouseMessage.getId()!=null){
            GreenhouseMessageMapper.updateByPrimaryKey(GreenhouseMessage);
        } else {
            GreenhouseMessageMapper.insert(GreenhouseMessage);
        }
    }

    @Override
    public void deleteById(long id) {
        GreenhouseMessageMapper.deleteByPrimaryKey(id);
    }
}